script_enemy_main{

let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let frame=120;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let GRboss=("\script\Images\CharacterSprites\Takeo.png");

@Initialize{
	LoadGraphic(GRboss);

if(GetArgument==0){
	SetColor(0,100,255);
	Concentration01(90);
	SetColor(255,255,255);
}
	SetLife(10000);
	MagicCircle(false);
	SetInvincibility(120);
	SetX(GetCommonData("Boss2X"));
	SetY(GetCommonData("Boss2Y"));
	SetMovePosition02(cx+100,miny+100,60);
}
	
@MainLoop{

SetCollisionB(GetX,GetY,16);


if(GetCommonData("Difficulty")==1){
if((time+200)%320==0 && time>=60){
	if(GetPlayerX>cx+30 && GetPlayerX<maxx-50){
	SetMovePosition01(GetPlayerX+rand(-30,30),rand(miny+80,miny+120),1.5);
	}
	if(GetPlayerX<=cx+30){
	SetMovePosition01(rand(cx+30,cx+60),rand(miny+80,miny+120),1.5);
	}
	if(GetPlayerX>=maxx-50){
	SetMovePosition01(rand(maxx-90,maxx-50),rand(miny+80,miny+120),1.5);
	}
}
} //Easy

//=============================================================

if(GetCommonData("Difficulty")==2){
if((time+190)%320==0 && time>=60){
	if(GetPlayerX>cx+30 && GetPlayerX<maxx-50){
	SetMovePosition01(GetPlayerX+rand(-30,30),rand(miny+80,miny+120),1.5);
	}
	if(GetPlayerX<=cx+30){
	SetMovePosition01(rand(cx+30,cx+60),rand(miny+80,miny+120),1.5);
	}
	if(GetPlayerX>=maxx-50){
	SetMovePosition01(rand(maxx-90,maxx-50),rand(miny+80,miny+120),1.5);
	}
}
} //Normal

//=============================================================

if(GetCommonData("Difficulty")==3){
if((time+190)%330==0 && time>=60){
	if(GetPlayerX>cx+30 && GetPlayerX<maxx-50){
	SetMovePosition01(GetPlayerX+rand(-30,30),rand(miny+80,miny+120),1.5);
	}
	if(GetPlayerX<=cx+30){
	SetMovePosition01(rand(cx+30,cx+60),rand(miny+80,miny+120),1.5);
	}
	if(GetPlayerX>=maxx-50){
	SetMovePosition01(rand(maxx-90,maxx-50),rand(miny+80,miny+120),1.5);
	}
}
} //Hard

//=============================================================

if(GetCommonData("Difficulty")==4){
if((time+180)%320==0 && time>=60){
	if(GetPlayerX>cx+30 && GetPlayerX<maxx-50){
	SetMovePosition01(GetPlayerX+rand(-30,30),rand(miny+80,miny+120),1.5);
	}
	if(GetPlayerX<=cx+30){
	SetMovePosition01(rand(cx+30,cx+60),rand(miny+80,miny+120),1.5);
	}
	if(GetPlayerX>=maxx-50){
	SetMovePosition01(rand(maxx-90,maxx-50),rand(miny+80,miny+120),1.5);
	}
}
} //Lunatic


time++;
frame++;

if(GetCommonData("UseSpell2")!=0){ usespell=GetCommonData("UseSpell2"); SetCommonData("UseSpell2",0); }
if(usespell>0){ usespell--; }
if(usespell<0){ usespell++; }

SetCommonData("Boss2X",GetX); SetCommonData("Boss2Y",GetY);

}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }
	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	DrawGraphic(GetX,GetY);
}

@Finalize{
	if(GetCommonData("Difficulty")<2){ CreateEnemyFromFile("script\Functions\dispel.txt",GetX,GetY,0,0,"Takeo"); }
	if(GetLife>0 && GetTimer>0){ CreateEnemyFromFile((GetCurrentScriptDirectory~"Tomomi-Takeo - Splashing The Pot - Takeo.txt"),GetCommonData("Boss1X"),GetCommonData("Boss1Y"),0,0,1); }
}

}